<template>
  <el-table-column
    v-if="isShow"
    :label="label"
    :prop="prop"
    :width="width"
    :min-width="minWidth"
    :sortable="sortable"
    :align="align"
    :class-name="className"
    :show-overflow-tooltip="showOverflowTooltip"
    :is-show="isShow"
    :fixed="fixed"
    :link-up="linkUp"
    :link-up-muti="linkUpMuti"
  >
    <template slot-scope="scope">
      <span v-if="filter === 'formatDate2'">{{ scope.row[prop] | formatDate2 }}</span>
      <el-link v-else-if="prop === linkUp && scope.row.subStatus == 1" type="primary" underline @click.stop="showMinXi(scope.row)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="prop === linkUp && scope.row.subStatus == 2" type="primary" underline @click.stop="showMinXi(scope.row)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="prop === linkUp && scope.row.subStatus == 3" type="primary" underline @click.stop="showMinXi(scope.row)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="prop === linkUp && scope.row.subStatus === undefined" type="primary" underline @click.stop="showMinXi(scope.row,prop)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="linkUpMuti.includes(prop) && scope.row.subStatus == 1" type="primary" underline @click.stop="showMinXiMuti(scope.row,prop)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="linkUpMuti.includes(prop) && scope.row.subStatus == 2" type="primary" underline @click.stop="showMinXiMuti(scope.row,prop)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="linkUpMuti.includes(prop) && scope.row.subStatus == 3" type="primary" underline @click.stop="showMinXiMuti(scope.row,prop)">{{ scope.row[prop] }}</el-link>
      <el-link v-else-if="linkUpMuti.includes(prop) && scope.row.subStatus === undefined" type="primary" underline @click.stop="showMinXiMuti(scope.row,prop)">{{ scope.row[prop] }}</el-link>
      <span v-else>{{ scope.row[prop] }}</span>
    </template>
  </el-table-column>
</template>
<script>
export default {
  name: 'Column',
  props: {
    label: { // 列标题 必须
      type: String,
      required: true
    },
    prop: { // 字段属性 必须
      type: String,
      required: true
    },
    width: { // 列的宽度  其值为固定的
      type: String
    },
    minWidth: { // 列最小宽度  与width相比min-width 会把剩余宽度按比例分配给设置了 min-width 的列
      type: String,
      default: '50px'
    },
    sortable: { // 是否支持排序 不传该属性则不支持排序，传的话其值为custom,表示远程排序
      type: String
    },
    align: { // 对齐方式
      type: String,
      default: 'center'
    },
    className: {
      type: String,
      default: 'small-padding fixed-width'
    },
    showOverflowTooltip: {
      type: Boolean,
      default: true
    },
    isShow: {
      type: Boolean,
      default: true
    },
    linkUp: {
      type: String,
      default: undefined
    },
    linkUpMuti: {
      type: Array,
      default: () => {
        return []
      }
    },
    val: {
      type: Number,
      default: undefined
    },
    fixed: {
      type: String
    },
    filter: {
      type: String
    }
  },
  mounted() {
    this
  },
  methods: {
    // 未提交已提交状态分别显示
    showMinXi(row) {
      this.$emit('update', row, 'showMinxi')
    },
    showMinXiMuti(row, prop) {
      this.$emit('update', row, 'showMinxi', prop)
    }
  }
}
</script>

<style scoped>

</style>
